<?php
			$get = $_GET;
			

			$FromExten	=	$get['FromExten']; //坐席账号
			$Exten		=	$get['Exten']; //号码

			$accountid	=	"N00000011697";//云呼账号 
			$secret		=	"806d1d40-15e8-11e7-b666-b5ef7e6226e3";//云呼密码
			$time		=	date("YmdHis");
//echo $time;exit;
			$authorization	=	base64_encode($accountid.":".$time);
			$sig			=	strtoupper(md5($accountid.$secret.$time));
//echo $authorization;
//echo "<br>";


			$url	=	"http://apis.7moor.com/v20170418/call/dialout/".$accountid."?sig=".$sig;
			$data	=	array("FromExten"=>$FromExten,"Exten"=>$Exten);

		
//print_r(  http_build_query($data) );exit;
//echo $url;
//exit;
	//echo strlen( http_build_query($data) );exit;
			//$header[] = 'Connection: Keep-Alive';
			$header[] = "Accept: application/json";
			$header[] = "Content-type: application/json;charset='utf-8'";
			$header[] = "Content-Length: ".strlen( json_encode($data) );
			$header[] = "Authorization: ".$authorization;



		//print_r($header);
	
			$ch = curl_init ();
			curl_setopt($ch, CURLOPT_URL, ($url) );//地址
			curl_setopt($ch, CURLOPT_POST, 1);   //请求方式为post
			curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($data)); //post传输的数据。
			curl_setopt($ch, CURLINFO_HEADER_OUT, true);
			curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
			curl_setopt($ch, CURLOPT_TIMEOUT, 60);

			//print_r($message);exit;

			$return = curl_exec ( $ch );
			
			if($return === FALSE ){
				echo "CURL Error:".curl_error($ch);exit;
			 }

			curl_close ( $ch );
	
	
			
		
		echo ($return);
		exit;



?>